str = "Hello python"
str1 = "Hello world"
str2 = "test"
str3 = "12345678"

# 依次获取上面字符串的长度，不能使用len
count = 0
for index in str:
    count += 1
print(f"{str}的长度为：{count}")

count = 0
for index in str1:
    count += 1
print(f"{str1}的长度为：{count}")

count = 0
for index in str2:
    count += 1
print(f"{str2}的长度为：{count}")

count = 0
for index in str3:
    count += 1
print(f"{str3}的长度为：{count}")

"""
函数定义：
def 函数名称(参数....):
    return 返回值

匿名函数：lambda 条件：返回值
"""
# add = lambda x,y:x+y
# print((lambda x,y:x+y)(1,2) )

def students(name,age,num):
    return f"姓名：{name}，年龄：{age}，学号：{num}"

# 位置参数-最常用
stu1 = students("张三",23,10001)
print(stu1)

# 关键字参数-无顺序
stu2 = students(num=10002,name="小明",age=25)
print(stu2)

# 缺省参数
stu3 = students("lisi",25,10000)
print(stu3)

# 不定长参数
def user(*args):
    print(type(args),args)
user(1,2.2,"xiaoxiao",'ssss')

def user1(**kwargs):
    print(type(kwargs),kwargs)
user1(name="小明",age=25)

# 多返回值
def sum(a,b,c):
    # return a+b+c
    return a+b+c,a,b,c
print(sum(1,2,3))
result,a,b,c = sum(1,2,3)
print(result)
print(a)
print(b)
print(c)


